//
//  RPCheckNote.m
//  yilutongxing
//
//  Created by T&J on 2017/6/14.
//  Copyright © 2017年 YZE. All rights reserved.
//

#import "RPCheckNote.h"
#import <MJExtension.h>
#import <GTMBase64.h>

@implementation RPImageChecknote
- (NSDictionary *)toDictionaryWithImageInBase64{
    NSMutableDictionary *tdic = [NSMutableDictionary dictionary];
    tdic[@"id"] = _id;
    tdic[@"title"] = _title;
    tdic[@"desc"] = _desc;
    tdic[@"imageurls"] = _imageurls;
    NSMutableArray *timagesEncoded = [NSMutableArray array];
    NSEnumerator *en = [_images objectEnumerator];
    UIImage *img = nil;
    while (img = [en nextObject]) {
        NSData *rawData = UIImageJPEGRepresentation(img, 1.0f);
        NSData *encodedData = [GTMBase64 encodeData:rawData];
        NSString *encodeStr = [[NSString alloc]initWithData:encodedData encoding:NSASCIIStringEncoding];
        [timagesEncoded addObject:encodeStr];
    }
    tdic[@"images"] = timagesEncoded;
    
    return tdic;
}
@end


@implementation RPCheckNote

+ (NSDictionary *)mj_objectClassInArray{
    return @{
             @"otherImagesDTO" : [RPImageChecknote class]
             };
}

- (NSDictionary *)toDictionaryWithImageInBase64{
    NSMutableDictionary *tdic = [NSMutableDictionary dictionary];
    tdic[@"checkTime"] = _checkTime?_checkTime:@" ";
    tdic[@"hospitalDTO"] = _hospitalDTO?[_hospitalDTO mj_keyValues]:@{};
    tdic[@"id"] = _id;
    //tdic[@"images"] = _images?_images:@[];
    tdic[@"imageurls"] = _imageurls;
    tdic[@"blood"] = _blood?[_blood mj_keyValues]:@{};
    tdic[@"bloodfat"] = _bloodfat?[_bloodfat mj_keyValues]:@{};
    tdic[@"bloodsugar"] = _bloodsugar?[_bloodsugar mj_keyValues]:@{};
    tdic[@"coagulation"] = _coagulation?[_coagulation mj_keyValues]:@{};
    tdic[@"hepatitis"] = _hepatitis?[_hepatitis mj_keyValues]:@{};
    tdic[@"immunologic"] = _immunologic?[_immunologic mj_keyValues]:@{};
    tdic[@"liver"] = _liver?[_liver mj_keyValues]:@{};
    tdic[@"liverTranSono"] = _liverTranSono?[_liverTranSono mj_keyValues]:@{};
    tdic[@"outineblood"] = _outineblood?[_outineblood mj_keyValues]:@{};
    tdic[@"renal"] = _renal?[_renal mj_keyValues]:@{};
    tdic[@"tumormarker"] = _tumormarker?[_tumormarker mj_keyValues]:@{};
    tdic[@"urinalysis"] = _urinalysis?[_urinalysis mj_keyValues]:@{};
    tdic[@"viralinfection"] = _viralinfection?[_viralinfection mj_keyValues]:@{};
    NSDictionary *bSdic = [_bSuperDTO toDictionaryWithImageInBase64];
    tdic[@"bSuperDTO"] = bSdic?bSdic:@{@"images":@[]};
    NSDictionary *bCTdic = [_ctDTO toDictionaryWithImageInBase64];
    tdic[@"ctDTO"] = bCTdic?bCTdic:@{@"images":@[]};
    NSDictionary *bMRIdic = [_mriDTO toDictionaryWithImageInBase64];
    tdic[@"mriDTO"] = bMRIdic?bMRIdic:@{@"images":@[]};
    NSDictionary *bBoneDic = [_boneScanningDTO toDictionaryWithImageInBase64];
    tdic[@"boneScanningDTO"] = bBoneDic?bBoneDic:@{@"images":@[]};
    NSDictionary *bECGdic = [_ecgDTO toDictionaryWithImageInBase64];
    tdic[@"ecgDTO"] = bECGdic?bECGdic:@{@"images":@[]};
    NSDictionary *bULTRAdic = [_ultrasonicCardiogramDTO toDictionaryWithImageInBase64];
    tdic[@"ultrasonicCardiogramDTO"] = bULTRAdic?bULTRAdic:@{@"images":@[]};
    NSDictionary *bPETdic = [_petCtDTO toDictionaryWithImageInBase64];
    tdic[@"petCtDTO"] = bPETdic?bPETdic:@{@"images":@[]};
    
    NSMutableArray *totherImagesDTO = [NSMutableArray array];
    NSEnumerator *en = [_otherImagesDTO objectEnumerator];
    RPImageChecknote *imgnote = nil;
    while (imgnote = [en nextObject]) {
        NSDictionary *imgnoteDic = [imgnote toDictionaryWithImageInBase64];
        [totherImagesDTO addObject:imgnoteDic];
    }
    tdic[@"otherImagesDTO"] = totherImagesDTO;
    
    return tdic;
}

@end
